#include <iostream>
using namespace std;

typedef struct intNode
{
    int data;
    intNode *next;
    intNode *pre;
} intNode;

typedef struct intSigleQueue
{
    intNode *front;
    intNode *rear;
} ISQ;

bool enqueue(ISQ *queue, int n)
{
    intNode *newNode = new intNode();
    newNode->data = n;
    if (queue->front==NULL){
        queue->front = newNode;
        queue->rear = newNode;
    }

    queue->rear->next = newNode;
    newNode->pre = queue->rear;
    queue->rear=newNode;
    return true;
}

int outqueue(ISQ *queue)
{
    if (queue->front==NULL)
        return -1;
    int res = queue->rear->data;
    if (queue->rear==queue->front)
    {
        queue->front ==NULL;
        queue->rear ==NULL;
    }
    queue->rear = queue->rear->pre;
    
    return res;
}

int rear(ISQ *queue)
{
    if (queue->front==NULL)
        return -1;
    return queue->rear->data;
}
ISQ *init()
{
    ISQ *queue = new ISQ();
    for (int i = 0; i < 10; i++)
    {
        enqueue(queue,i+1);
    }
    for (int i = 0; i < 5; i++)
    {
        outqueue(queue);
    }
    for (int i = 0; i < 7; i++)
    {
        enqueue(queue,i+50);
    }
    return queue;
}
int main(int argc, char const *argv[])
{
    ISQ *s = init();
    printf("%d,%d", rear(s), outqueue(s));
    return 0;
}
